package stark.app.function.photomovie;

import android.content.Intent;
import android.net.Uri;

import com.blankj.utilcode.util.ToastUtils;
import com.stark.picselect.config.PhotoConfig;
import com.stark.picselect.entity.SelectMediaEntity;
import com.stark.pmu.PhotoMovieActivity;
import com.stark.pmu.PhotoMovieEntry;
import com.stark.video.player.VideoPlayerActivity;

import java.util.ArrayList;

import androidx.annotation.Nullable;
import stark.app.MediaSelectUtil;
import stark.app.R;
import stark.app.databinding.ActivityPhotoMovieDemoBinding;
import stark.common.basic.base.BaseNoModelActivity;

/**
 * Author：daizhongbin on 2021/8/30
 * Email：1027154338@qq.com
 * Desc:
 */
public class PhotoMovieDemoActivity extends BaseNoModelActivity<ActivityPhotoMovieDemoBinding> {

    private static final int REQ_PHOTO_MOVIE_RET = 1;

    @Override
    protected int onCreate() {
        return R.layout.activity_photo_movie_demo;
    }

    @Override
    protected void initView() {
        mDataBinding.btnPhotoMovie.setOnClickListener(v -> {
            MediaSelectUtil.pickMedia(this, PhotoConfig.Mode.PHOTO, 9, data -> {
                if (data == null || data.size() == 0) {
                    return;
                }
                ArrayList<String> pathList = new ArrayList<>();
                for (SelectMediaEntity entity : data) {
                    pathList.add(entity.getTargetPath());
                }
                PhotoMovieEntry.enterPhotoMovieForRet(PhotoMovieDemoActivity.this, pathList, REQ_PHOTO_MOVIE_RET);
            });
        });
    }

    @Override
    protected void initData() {
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == REQ_PHOTO_MOVIE_RET) {
                Uri uri = data.getData();
                ToastUtils.showShort("保存的视频uri为：" + uri.toString());
            }
        }
    }
}
